package apiPractice;

import java.util.Objects;

public class pratice05 {
    public static void main(String[] args) {
        people p1=new people("王大喵",11);
        people p2=new people("王大喵",11);
        System.out.println(p1.equals(p2));
        System.out.println(p1 == p2);
        System.out.println(p1.name == p2.name);
        System.out.println(p1.age == p2.age);
        System.out.println(p1);
    }
}
class people{
    String name;
    int age;
    public people() {
    }
    public people(String name, int age) {
        super();
        this.name = name;
        this.age = age;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        people people = (people) o;
        return age == people.age && Objects.equals(name, people.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(name, age);
    }

    @Override
    public String toString() {
        return "people{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}